package priv.ln.encapsulation.exer1;

/**
 * ClassName: Person
 * Package: priv.ln.encapsulation.exer1
 * Description:
 *用setAge()设置人的合法年龄(0~130)，用getAge()返回人的年龄。
 * @Author 辣辣
 * @Create 2024/6/21 16:49
 * @Version 1.0
 */
public class Person {
    private int age;

    public void setAge(int num) {
        if(num >= 0 && num <= 130){
            age = num;
        }else{
            System.out.println("非法输入");
        }
    }

    public int getAge() {
        return age;
    }
}
